/**
 * Created by leedsjung on 2016/12/12.
 */
//date format
Date.prototype.format = function (pattern) {//yyyy MM dd HH mm ss
    if (!pattern) pattern = 'yyyy-MM-dd HH:mm:ss';
    function s(num) {
        if(num < 10) return '0'+num;
        else return ''+num;
    }
    var fullYear = this.getFullYear();
    var month = s(this.getMonth() + 1);
    var date = s(this.getDate());
    var hour = s(this.getHours());
    var minute = s(this.getMinutes());
    var second = s(this.getSeconds());
    return pattern.replace('yyyy', fullYear).replace('MM', month).replace('dd', date).replace('HH', hour).replace('mm', minute).replace('ss', second);
}